package my.servlet;

import org.apache.commons.lang.StringUtils;

public class StringView {

	public static final String TYPE_VIEW_JOSN = "json";
	public static final String TYPE_VIEW_STRING = "string";
	public static final String TYPE_VIEW_XML = "xml";

	private Object data;
	private String type;

	public StringView() {
	}

	public StringView(Object data) {
		this.data = data;
		this.type = TYPE_VIEW_JOSN;
	}

	public StringView(Object data, String type) {
		this.data = data;
		this.type = type;
	}

	public Object getData() {
		return data == null ? "" : data;
	}

	public void setData(Object data) {
		this.data = data;
	}

	public String getType() {
		if (StringUtils.isBlank(type)) {
			return TYPE_VIEW_STRING;
		}
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

}
